package org.example.Server.controller.homework;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.homework.HmkStuDTO;
import org.example.Server.service.homework.StuHmkService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/youxich/homework/stu")
public class HmkStuController {
    @Autowired
    private StuHmkService stuHmkService;

    /**
     * 获取作业列表
     *
     * @param semester_id
     * @param user_id
     * @return
     */
    @GetMapping
    public ResultAPI getHmkList(@RequestParam Integer semester_id, @RequestParam Integer user_id) {
        return stuHmkService.getHmkStuList(semester_id, user_id);
    }


    /**
     * 获取学生作业情况概览（那个表格
     *
     * @param user_id
     * @param hmk_id
     * @return
     */
    @GetMapping("review")
    public ResultAPI getStuHmkReview(@RequestParam Integer user_id, @RequestParam Integer hmk_id) {
        return stuHmkService.getStuHmkReview(user_id, hmk_id);
    }

    /**
     * 学生提交作业
     *
     * @param hmkStu
     * @return
     */
    @PostMapping("submit")
    public ResultAPI submitStuHmk(@RequestBody HmkStuDTO hmkStu) {
        return stuHmkService.submitStuHmk(hmkStu);
    }

    /**
     * 学生修改作业
     *
     * @param hmkStu
     * @return
     */
    @PutMapping("submit")
    public ResultAPI updateStuHmk(@RequestBody HmkStuDTO hmkStu) {
        return stuHmkService.updateStuHmk(hmkStu);
    }

    /**
     * 获取学生查看作业详情
     *
     * @param stu_hmwk_id
     * @return
     */
    @GetMapping("submit")
    public ResultAPI showSubmit(@RequestParam Integer stu_hmwk_id) {
        return stuHmkService.showSubmit(stu_hmwk_id);
    }

    /**
     * 学生获取互评列表
     *
     * @param hmk_id
     * @param user_id
     * @return
     */
    @GetMapping("each")
    public ResultAPI geteachList(@RequestParam Integer hmk_id, @RequestParam Integer user_id) {
        return stuHmkService.geteachList(hmk_id, user_id);
    }

    /**
     * 学生获取自己给别人作业的互评详情
     *
     * @param stu_hmk_id
     * @param user_id
     * @return
     */
    @GetMapping("each/detail")
    public ResultAPI getEachDetail(@RequestParam Integer stu_hmk_id, @RequestParam Integer user_id) {
        return stuHmkService.getEachDetail(stu_hmk_id, user_id);
    }
}
